package snooker.scoreboard;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;

public class ResizedButton {
	private Bitmap resizedBitmap;
	
	public ResizedButton(Resources r, int resource) {
		Bitmap originalBitmap = BitmapFactory.decodeResource(r, resource);
		int width = originalBitmap.getWidth(); 
		int height = originalBitmap.getHeight(); 
		int newWidth = 50; 
		int newHeight = 50; 
		
		// calculate the scale - in this case = 0.4f 
		float scaleWidth = ((float) newWidth) / width; 
		float scaleHeight = ((float) newHeight) / height; 
		
		// create a matrix for the manipulation 
		Matrix matrix = new Matrix(); 
		// resize the bit map 
		matrix.postScale(scaleWidth, scaleHeight); 

		// recreate the new Bitmap 
		resizedBitmap = Bitmap.createBitmap(originalBitmap, 0, 0, 
							  width, height, matrix, true); 
		
	}
	
	public Bitmap getBitmap() {
		return resizedBitmap;
	}
}
